package com.spic.business.datamanagement.violation.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.spic.business.datamanagement.violation.domain.ViolationActionInputDirty;
import com.spic.business.datamanagement.violation.mapper.ViolationActionInputDirtyMapper;
import com.spic.business.datamanagement.violation.service.IViolationActionInputDirtyService;
import com.spic.business.violation.supervision.action.mapper.ViolationActionInputMapper;
import com.spic.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 违章行为录入Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-11-26
 */
@Service
public class ViolationActionInputDirtyServiceImpl implements IViolationActionInputDirtyService
{
    @Autowired
    private ViolationActionInputDirtyMapper violationActionInputDirtyMapper;

    @Autowired
    private ViolationActionInputMapper violationActionInputMapper;

    /**
     * 查询违章行为录入
     * 
     * @param id 违章行为录入主键
     * @return 违章行为录入
     */
    @Override
    public ViolationActionInputDirty selectViolationActionInputDirtyById(Long id)
    {
        return violationActionInputDirtyMapper.selectViolationActionInputDirtyById(id);
    }

    /**
     * 查询违章行为录入列表
     * 
     * @param violationActionInputDirty 违章行为录入
     * @return 违章行为录入
     */
    @Override
    public List<ViolationActionInputDirty> selectViolationActionInputDirtyList(ViolationActionInputDirty violationActionInputDirty)
    {
        return violationActionInputDirtyMapper.selectViolationActionInputDirtyList(violationActionInputDirty);
    }

    /**
     * 新增违章行为录入
     * 
     * @param violationActionInputDirty 违章行为录入
     * @return 结果
     */
    @Override
    public int insertViolationActionInputDirty(ViolationActionInputDirty violationActionInputDirty)
    {
        violationActionInputDirty.setCreateTime(DateUtils.getNowDate());
        return violationActionInputDirtyMapper.insertViolationActionInputDirty(violationActionInputDirty);
    }

    /**
     * 修改违章行为录入
     * 
     * @param violationActionInputDirty 违章行为录入
     * @return 结果
     */
    @Override
    public int updateViolationActionInputDirty(ViolationActionInputDirty violationActionInputDirty)
    {
        violationActionInputDirty.setUpdateTime(DateUtils.getNowDate());
        return violationActionInputDirtyMapper.updateViolationActionInputDirty(violationActionInputDirty);
    }

    /**
     * 批量删除违章行为录入
     * 
     * @param ids 需要删除的违章行为录入主键
     * @return 结果
     */
    @Override
    public int deleteViolationActionInputDirtyByIds(Long[] ids)
    {
        return violationActionInputDirtyMapper.deleteViolationActionInputDirtyByIds(ids);
    }

    /**
     * 删除违章行为录入信息
     * 
     * @param id 违章行为录入主键
     * @return 结果
     */
    @Override
    public int deleteViolationActionInputDirtyById(Long id)
    {
        return violationActionInputDirtyMapper.deleteViolationActionInputDirtyById(id);
    }

    @Override
    public Map<String, Integer> statistics() {
        Integer all = 0, allDirty = 0, incomplete = 0, incorrect = 0;
        Map<String, Integer> map = new HashMap<>();
        all = violationActionInputMapper.selectCount(new QueryWrapper<>());
        allDirty = violationActionInputDirtyMapper.selectCount(new QueryWrapper<>());
        map.put("all", all);
        map.put("allDirty", allDirty);
        map.put("incomplete", incomplete);
        map.put("incorrect", allDirty);
        return map;
    }
}
